local sk__shunshi = fk.CreateSkill {

  name = "sk__shunshi",

  tags = {},

}



sk__shunshi:addEffect(fk.TargetConfirming, {
  name = "sk__shunshi",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__shunshi.name) and
        (data.card.type == Card.TypeBasic or data.card:isCommonTrick()) and
        data.from ~= player and #data:getAllTargets() == 1 and
        #data:getExtraTargets({ bypass_distances = true }) > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = room:askForChoosePlayers(player,
      table.map(data:getExtraTargets({ bypass_distances = true }), Util.IdMapper), 1, 3,
      "#sk__shunshi-choose:::" .. data.card:toLogString(), sk__shunshi.name, true)
    if #tos > 0 then
      event:setCostData(self, tos)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = table.map(event:getCostData(self), function(id) return room:getPlayerById(id) end)
    room:sortByAction(tos)
    data:addTarget(tos)
    player:drawCards(#tos, sk__shunshi.name)
  end,
})

return sk__shunshi
